package com.zhishu.portal.action;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.zhishu.portal.service.MyService;
import com.zhishu.portal.service.UserService;
import com.zhishu.portal.util.Const;

@Controller
@RequestMapping("/action/my")
public class MyAction extends BaseAction {
	private static Logger logger = Logger.getLogger(MyAction.class);
	@Resource
	private UserService userService;
	@Resource
	private MyService myService;

	@RequestMapping(value = "/m/toMyCenter")
	public ModelAndView toMyCenter(HttpServletRequest request, HttpServletResponse response) throws Exception {

		ModelAndView view = new ModelAndView();
		try {

			view.setViewName("/web/my/my_center.jsp");

		} catch (Exception e) {
			logger.error("", e);
			return null;
		}
		return view;
	}

	@RequestMapping(value = "/m/logout")
	public ModelAndView logout(HttpServletRequest request, HttpServletResponse response) throws Exception {

		ModelAndView view = new ModelAndView();
		try {
			request.getSession().removeAttribute(Const.SESSION_KEY);

			view.setViewName("redirect:/");

		} catch (Exception e) {
			logger.error("", e);
			return null;
		}
		return view;
	}

}
